hvmloader: Simplify 32bit-bios relocator.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 15 Mar 2007 10:38:06 +0000 (10:38 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 15 Mar 2007 10:38:06 +0000 (10:38 +0000)
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
tools/firmware/hvmloader/32bitbios_support.c

index f9274090cc139b9dad3b829c39e4959974e156fa..bfde19577fcb156ba7e41a39fe74369822029642 100644 (file)
@@ -45,16 +45,11 @@ static int relocate_elf(unsigned char *elfarray) {
         return -1;
     }
 
-    for (i = 0; i < ehdr->e_shnum; i++) {
-        if (!(shdr[i]).sh_flags & SHF_ALLOC) {
-            shdr[i].sh_addr = 0;
-            continue;
-        }
+    for (i = 0; i < ehdr->e_shnum; i++)
         shdr[i].sh_addr = (Elf32_Addr)&elfarray[shdr[i].sh_offset];
-    }
 
     for (i = 0; i < ehdr->e_shnum; i++) {
-        if (shdr[i].sh_type == SHT_REL && shdr[i].sh_addr != 0) {
+        if (shdr[i].sh_type == SHT_REL) {
             Elf32_Shdr *targetsec = (Elf32_Shdr *)&(shdr[shdr[i].sh_info]);
             Elf32_Shdr *symtabsec = (Elf32_Shdr *)&(shdr[shdr[i].sh_link]);
             Elf32_Sym  *syms      = (Elf32_Sym *)symtabsec->sh_addr;
@@ -62,6 +57,10 @@ static int relocate_elf(unsigned char *elfarray) {
             unsigned char *code   = (unsigned char *)targetsec->sh_addr;
             int j;
 
+            /* must not have been stripped */
+            if (shdr[i].sh_size == 0)
+                return -6;
+
             for (j = 0; j < shdr[i].sh_size / sizeof(Elf32_Rel); j++) {
                 int idx           = ELF32_R_SYM(rels[j].r_info);
                 Elf32_Sym *symbol = &syms[idx];